#include('head.html', {title : '找回密码'})
<body class="bg-info dker">
<section id="content" class="m-t-lg wrapper-md animated fadeInUp">
  <div class="container aside-xl">
    <a class="navbar-brand block" href="signin"><span class="h1 font-bold">找回密码</span></a>
    <section class="m-b-lg">
      <header class="wrapper text-center">
        <strong>皖西学院创客实验室成员管理系统</strong>
      </header>

      <style>
        . {
          width:800px;
          font-family:'黑体';
          margin:50px auto;
          margin: 0%;
          padding: 0%;
        }

        #mm,#yx{
          font-size: 12px;
          color: #FAF5FF;
          padding-left: 20px;
          display: block;
          text-align: center;
        }
        .wrong{
          background:url(/static/images/wrong.png) no-repeat  4px 3px;
          /*border: 1px solid #FFAC91;*/
          border: hidden;
          height:32px;
          line-height:32px;
          color:#FF0000 !important;
        }

        .right{
          /*color: #5EFF5E !important;*/
          background:url(/static/images/right.png) no-repeat 4px 3px;
          /*border: 1px solid #ACFFAC;*/
          height:32px;
          border: hidden;
          line-height:32px;
        }
        .form-group .default{
          width:200px;
          height:32px;
          line-height:32px;
          color:#999;
        }
      </style>
      <script type="text/javascript">
          function checkPassword(){
              var userpasswd = document.getElementById('mima').value;
              var reg = /^.*[~!@#\$%\^&\*\(\)_+\-=\[\]\{\}\\\|\'\";:,\<\.\>\/\?\s+].*$/;
              var regNumber = /\d+/; //验证0-9的任意数字最少出现1次。
              var regString = /[a-zA-Z]+/; //验证大小写26个字母任意字母最少出现1次。
              if(userpasswd.length == 0){
                  document.getElementById('passwordErr').innerHTML="密码不能为空";
                  document.getElementById('passwordErr').className="error";
                  return false;
              }
              else if(userpasswd.length<6){
                  document.getElementById('passwordErr').innerHTML="密码长度要大于6个字符";
                  document.getElementById('passwordErr').className="error";
                  return false;
              }
              else if(!(regNumber.test(userpasswd) && regString.test(userpasswd) || reg.test(userpasswd))){
                  document.getElementById('passwordErr').className="error";
                  document.getElementById('passwordErr').innerHTML="密码中要包含字符串、数字可包含特殊符号！";
                  return false;
              }
              else{
                  document.getElementById('passwordErr').className="success";
                  document.getElementById('passwordErr').innerHTML="正确";
                  return true;
              }
          }

          //确认密码
          function ConfirmPassword(){
              var userpasswd = document.getElementById('mima');
              var userConPassword = document.getElementById('password');
              var errConPasswd = document.getElementById('conPasswordErr');
              if((userpasswd.value)!=(userConPassword.value) || userConPassword.value.length == 0){
                  errConPasswd.innerHTML="上下密码不一致";
                  errConPasswd.className="error";
                  return false;
              }
              else{
                  errConPasswd.innerHTML="OK";
                  errConPasswd.className="success";
                  return true;
              }
          }
      </script>

      <form>
        <input type="hidden" value="${email}" id="email">
        <input type="hidden" value="${ecode}" id="ecode">
        <div class="form-group">
          <input type="password" name="password" placeholder="输入新密码" id="mima" onblur="checkPassword()" class="form-control rounded input-lg text-center no-border">
          <span class="default" id="passwordErr">请输入6位以上位的密码</span>
        </div>
        <div class="form-group">
          <input type="password" name="password" placeholder="再次输入密码" id="password" onblur="ConfirmPassword()" class="form-control rounded input-lg text-center no-border">
          <span class="default" id="conPasswordErr">请输入6位以上位的密码</span>
        </div>
        <button type="button" class="btn btn-lg btn-warning lt b-white b-2x btn-block btn-rounded"><i class="icon-arrow-right pull-right"></i><span class="m-r-n-lg">确认修改</span></button>

      </form>
    </section>
  </div>
</section>
#include('footer.html')
#include('js.html')
<script>
  $(".btn-rounded").click(function(){
      checkPassword();
      if($("#passwordErr").hasClass("success")&&$("#conPasswordErr").hasClass("success")){
          $.post("/forgotPassword",{
              email :  $('#email').val(),
             password : $('#mima').val(),
             code : $('#ecode').val()
          },function (data, status) {
            if(data.state==200){
               alert(data.message);
               window.location = "/signin";
            }
            else{
               alert(data.message);
               window.location = "/";
            }
          })
      }
  });

</script>
</body>
</html>